package com.hq.ims.userpc.controller;

import com.hq.ims.data.annotation.UserOperationMonitor;
import com.hq.ims.data.entity.User;
import com.hq.ims.data.entityenum.EnumAccountStatus;
import com.hq.ims.data.service.BaseUserService;
import com.hq.ims.data.utils.LocalConstant;
import com.hq.ims.data.vo.UserMapstruct;
import com.hq.mybatis.base.page.RequestPage;
import com.hq.mybatis.base.page.ReturnPage;
import com.hq.utils.util.ObjectUtils;
import com.hq.utils.vo.ReturnVo;
import com.hq.web.annotations.GetJsonValue;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统管理中心Controller
 */
@Api(tags = "用户信息")
@RestController
@RequestMapping(LocalConstant.SYS_TYPE_USER_PC_URL_PREFIX + "/user")
public class UserController {

    @Resource
    private BaseUserService baseUserService;

    @ApiOperation(value = "根据部门获取用户(分页)", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
    })
    @PostMapping(value = "/getPageByDepartmentId")
    public ReturnVo<ReturnPage<UserMapstruct.UserAndCompanySimpleVo>> getPageByDepartmentId(
            @RequestBody RequestPage page,
            @GetJsonValue(required = false) UserMapstruct.PageSearchVo searchVo,
            @GetJsonValue(zh = "部门iD") String companyDepartmentId
    ) {
        List<UserMapstruct.UserAndCompanySimpleVo> userAndCompanySimpleVoList = baseUserService.getPageByDepartmentId(page, searchVo, companyDepartmentId);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }

    @ApiOperation(value = "根据公司获取用户(分页)", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
    })
    @PostMapping(value = "/getPageByCompanyId")
    public ReturnVo<ReturnPage<UserMapstruct.UserAndCompanySimpleVo>> getPageByCompanyId(
            @RequestBody RequestPage page,
            @GetJsonValue(required = false) UserMapstruct.PageSearchVo searchVo,
            @GetJsonValue(zh = "公司ID") String companyId
    ) {
        List<UserMapstruct.UserAndCompanySimpleVo> userAndCompanySimpleVoList = baseUserService.getPageByCompanyId(page, searchVo, companyId);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }



}
